#!/bin/bash
currentcpuload=`uptime | awk -F"load average:" '{print $NF}'|awk -F" " '{print $1}'|awk -F"." '{print $1}'`
if [ $currentcpuload -ge 100 ];then
    echo "cpuload is $currentcpuload"
    exit $CRITICAL
fi
script=$(cd `dirname $0`; pwd)"/"$(basename $0)
runnum=`ps aux | grep $script | wc -l`
if [ $runnum -gt 3 ];then
exit
fi
date=`date +%s`
day=`date +%d`
dirpath="/var/log/afscachestat/"
objstr=`fs getcacheparm -excessive | tr "\n" ";"`
echo $date" "$objstr > $dirpath"afscache_"$date".data"
#nvidia-smi stats -d pwrDraw,temp,memUtil,gpuUtil -c 1 -f $dirpath"gpumon_"$date".data"
find $dirpath -cmin +1200 -name "afscache_*"  -exec /bin/rm -rf {} \;
